#ifndef DIAGRAMCTRL_H
#define DIAGRAMCTRL_H

#include <QObject>
#include <QRectF>
#include <QPushButton>
#include <QLabel>
#include <QMouseEvent>
#include <QDebug>

struct RectCtrl
{
    bool dragging;
    bool henbale;
    bool venbale;
    bool show;
    QRectF rect;
};

typedef struct DiagramCtrlParameter
{
    RectCtrl center;    // 频率/增益调节框
    RectCtrl left;      // Q值左侧调节框
    RectCtrl right;     // Q值右侧调节框
    RectCtrl ttxt;      // 频率/增益/Q值文本框
    QString ctxt;       // center文本
    QString tip;        // 频率/增益/Q值文本
    int bw;
    double freq;
    double gain;
}DCParam;

class DiagramCtrl : public QObject
{
    Q_OBJECT
public:
    explicit DiagramCtrl(QObject *parent = nullptr);
public slots:
    void move(const QPointF &p);
    void setBw(const int &bw);
    void setFreqGain(const double &freq, const double &gain);
signals:
private:
    DCParam m_param;
};

struct DragPushButton
{
    bool dragging;
    QPushButton *button;
};

class DCtrlPushButton : QWidget
{
    Q_OBJECT
public:
    explicit DCtrlPushButton(const QString &text, bool hideLR = false, QWidget *parent = nullptr);
public slots:
    void moveCenter(const QPoint &p);
    void moveLR(const unsigned int &offsetx);
protected:
    bool eventFilter(QObject *watched, QEvent *event) override;

private:
    DragPushButton center;
    DragPushButton left;
    DragPushButton right;
};


#endif // DIAGRAMCTRL_H
